package com.hui.platform.falseworkapi.common.core.constant;

import com.hui.platform.falseworkapi.common.core.ICodeMessage;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 一级状态码为http状态码：
 * Http的通用结果码：200,400,500,404,401,403等等
 * <p>
 * 二级状态码：
 * <p>
 * 返回结果状态码（二级，基于一级状态码的200）
 *
 * @author Peng
 * @date 2019/10/23
 */
@AllArgsConstructor
public enum ResultCodeEnum implements ICodeMessage {

    // ----------- 1xxx Informational -----------

    // ----------- 2xxx Success -----------
    /**
     * 正常成功: 200-2000
     */
    SUCCESS(2000, "result.success", "请求成功"),

    // ----------- 3xxx Redirection -----------

    // ----------- 4xxx Client Error -----------
    /**
     * 参数校验错误: 400-4000
     */
    VALIDATE_FAILED(4000, "result.validate-failed", "参数错误"),
    /**
     * 未认证: 401-4001
     */
    UNAUTHORIZED(4001, "result.unauthorized", "未登录"),
    /**
     * 未授权: 403-4003
     */
    FORBIDDEN(4003, "result.forbidden", "没有权限"),
    /**
     * 客户端未知错误: 404-4004
     */
    CLIENT_ERROR(4004, "result.client-error", "客户端未知错误"),

    // --- 5xxx Server Error ---
    /**
     * 未知错误: 500-5000
     */
    UNKNOWN_FAILED(5000, "result.unknown-failed", "系统异常"),
    /**
     * 业务异常: 500-5001
     */
    BUSINESS_FAILED(5001, "result.business-failed", "业务异常"),
    /**
     * 自定义异常:: 500-5002
     */
    CUSTOM_FAILED(5002, "result.custom-failed", "自定义异常"),
    ;

    @Getter
    private long code;
    @Getter
    private String key;
    @Getter
    private String message;
}
